﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.XtraReports.UI;

public partial class Store_Keeper_SK_Rpt_GRN : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
        {
            Session["current"] = "GRN Report";//current page

            if (Session["user"] != null)//check user
            {
                string user = Session["user"].ToString();
                if (user == "viewer")
                {
                    Response.Redirect("index.aspx");
                }

            }
            else
            {
                Response.Redirect("index.aspx");
            }
            ReportViewer1.Report = CreateReport();
        }

        XtraReport CreateReport()
        {

            //RPT_GRN report = new RPT_GRN();
            Rpt_GRN report = new Rpt_GRN();
            report.GRN.Value = GetSelectedValue(1);
            if (report.GRN.Value.ToString() == "1")
            {
            }
            else
            {
                report.CreateDocument();

            }
            return report;
        }

        int GetSelectedValue(int defaultValue)
        {
            if (DropDownList1.SelectedItem != null)
            {
                return Convert.ToInt32(DropDownList1.SelectedItem.Value) ;
            }
            else
            {
                return defaultValue;
            }
        }




        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

            ReportViewer1.Report = CreateReport();
        }
}
